﻿#pragma once
#if defined(_MSC_VER)
    #define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct Uni {
    union {
        int u1;
        char u2[10];
    };
    int c;
} uni;

typedef struct S0 {
    float a, b;
} s0;

typedef struct S1 {
    union {
        struct {
            float x, y, z, w;
        };
        struct {
            s0 s1, s2; // 这里使得 x = s1.a, y = s1.b, z = s2.a, w = s2.b
        };
    };
} s1;

/*
// C++ TestClass 头文件中如果包含类，则自动使用 C++ 语法
class TestClass {
public:
    int add(int a, int b) { return a + b; };
    int sub(int a, int b) { return a - b; };
    int mul(int a, int b) { return a * b; };
    int div(int a, int b) { return a / b; };

    void set_name(char* name) {
        this->name = name;
    }

    void print_name() {
        printf("This is a test class. name: %s\n", name);
    }
private:
    char* name;
}; // 所以如果 .c 文件包含 class 头文集会报错
*/

